/*
	Copyright (c) 2012 by karmaleaving@qq.com. All rights RESERVED.
*/
#ifndef __STD_SET_H_VERSION_KL__
#define __STD_SET_H_VERSION_KL__

#include "btree.h"
// CLASS set, multiset {
KL_BEGIN
template<typename Type, typename Less = KL::less<Type>, 
	typename Allocate = KL::allocator<Type>>
class set : public KL::btree<Type, Less, Allocate, false>
{
private:
	typedef KL::btree<Type, Less, Allocate, false> _base;
public:
	typedef typename _base::const_iterator iterator; // const.
	typedef typename _base::const_reverse_iterator reverse_iterator; // const.
public:
	set()
	{
	}
	set(set const &o)
		: _base(o)
	{
	}
	set & operator = (set const &o)
	{
		if(&o == this) return *this;
		*(_base*)this = (_base)o;
		return *this;
	}
};
template<typename Type, typename Less = KL::less<Type>, 
	typename Allocate = KL::allocator<Type>>
class multiset : public KL::btree<Type, Less, Allocate, true>
{
private:
	typedef KL::btree<Type, Less, Allocate, true> _base;
public:
	typedef typename _base::const_iterator iterator; // const.
	typedef typename _base::const_reverse_iterator reverse_iterator; // const.
public:
	multiset()
	{
	}
	multiset(multiset const &o)
		: _base(o)
	{
	}
	multiset & operator = (multiset const &o)
	{
		if(&o == this) return *this;
		*(_base*)this = (_base)o;
		return *this;
	}
};
// CLASS set, multiset }
// FUNCTION swap (for set) {
template<typename Type, typename Less, typename Allocate>
inline void swap(set<Type, Less, Allocate> &left, set<Type, Less, Allocate> &right)
{
	left.swap(right);
}
template<typename Type, typename Less, typename Allocate>
inline void swap(multiset<Type, Less, Allocate> &left, 
				 multiset<Type, Less, Allocate> &right)
{
	left.swap(right);
}
// FUNCTION swap (for set) }
KL_END
#endif // __STD_SET_H_VERSION_KL__
